package com.yyh.json;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @JsonProperty("name")
    private String name;
    private int age;
    private String sex;
    private String[] hobbies;

    public User() {
    }

    public User(String name, int age, String sex, String[] hobbies) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.hobbies = hobbies;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String[] getHobbies() {
        return hobbies;
    }

    public void setHobbies(String[] hobbies) {
        this.hobbies = hobbies;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return age == user.age && Objects.equals(name, user.name) && Objects.equals(sex, user.sex) && Arrays.equals(hobbies, user.hobbies);
    }

    @Override
    public int hashCode() {
        int result = Objects.hash(name, age, sex);
        result = 31 * result + Arrays.hashCode(hobbies);
        return result;
    }

    @Override
    public String toString() {
        return "User = {" +
                "name=" + name + '\'' +
                ",age=" + age +
                ",sex='" + sex + '\'' +
                ",hobbies=" + Arrays.toString(hobbies) +
                '}';
    }
}
